-- ======================================================================
-- Hell Lua Bus
-- 
-- Copyright 2012-2013Hell-Prototypes
--
-- http://www.hellprototypes.com/
--
-- This is free software, licensed under the terms of the GNU General
-- Public License as published by the Free Software Foundation.
-- ======================================================================
module(..., package.seeall);

function table(tab, flag, linelen)

	if type(linelen) ~= "number" then
		linelen = 16
	end

	if type(tab) == "table" then
		if flag then
			print("\r\n============= Table size = " .. #tab .. "B ==============")
		end
		for i=1, #tab do
			io.write(string.format("%02x ", tab[i]):upper())
			if i%linelen == 0 then
				print("")
			end
		end
		if flag then
			print("\r\n===============================================")
		else
			print("")
		end
	else
		print("<Print> Error: Not a table param.")
		return
	end
end

function bin(str, flag)
    if type(tab) == "string" then
        if flag then
    		print("\r\n============= String size = " .. #str:len() .. "B ==============")
    	end

        for i=1, str:len() do
            io.write(string.format("%02xH ", str:byte(i)):upper())
            if i%16 == 0 then
            	print("")
            end
        end

        if flag then
			print("\r\n===============================================")
		else
			print("")
		end
	else
		print("<Print> Error: Not a String param.")
		return
	end
end